<template>
  <div class="infos" style="width:99%;">
    <div>
      <Card-info
        :cardList="dataList"
        tileBgc="#59B9FF"
        titleLabel="基础信息"
        v-if="mychinaedu"
      ></Card-info>
      <!-- 学校客户 -->
      <Card-SchoolInfo
        :schoolInfo="schoolInfo"
        tileBgc="#59B9FF"
        titleLabel="基础信息"
        v-if="myschool"
      ></Card-SchoolInfo>
      <Card-SignInfo
        :investmentSignInfo="investmentSignInfo"
        tileBgc="#FF4F00"
        titleLabel="签约信息"
        v-if="mychinaedu"
      ></Card-SignInfo>
      <div
        class="toSeeTrackingInfo"
        @click="toSeeTrackingInfo"
        v-if="mychinaedu"
      >
        查看跟进情况
      </div>
      <div
        class="toSeeTrackingInfo"
        @click="toSeeTrackingInfo"
        v-if="myschool"
      >
        查看报备情况
      </div>
      <!-- <div class="trackingBox"  v-if="mychinaedu">
        <div class="trackingBoxTitle">跟进情况</div>
        <Card-Tracking :cardTrackingData="cardTrackingData" @upCallback='upCallback'></Card-Tracking>
      </div> -->

      <!-- <div class="trackingBox" v-if="myschool">
        <div class="trackingBoxTitle" v-if="myschool">报备情况</div>
        <Card-Tracking :cardTrackingData="recordInfoData"></Card-Tracking>
      </div> -->
    </div>
  </div>
</template>

<script>
import Cookies from "js-cookie";
import axios from "axios";
import CardInfo from "../components/CardInfo";
import CardSignInfo from "../components/CardSignInfo";
import CardTracking from "../components/CardTracking";
import CardSchoolInfo from "../components/CardSchoolInfo";

export default {
  name: "CustomerInfo",
  components: {
    CardInfo,
    CardTracking,
    CardSignInfo,
    CardSchoolInfo
  },
  data() {
    return {
      instance: "",
      isRouterAlive: true,
      brandFold: true,
      basisInfo: {},
      agentSignInfoData: {},
      dataList: {},
      investmentSignInfo: {},
      schoolInfo: {},
      cardTrackingData: [],
      recordInfoData: [],
      iscardTrackingDataBlank: true,
      queryName: this.$route.query.name,
      myschool: false,
      mychinaedu: false,
      page: {
        pageNum: 1,
        pageSize: 10
      },
      investmentDataFromType:[]
    };
  },
  methods: {
    // 展开收起
    changeFoldState() {
      this.brandFold = !this.brandFold;
    },
    toSeeTrackingInfo() {
      if(this.queryName=='mychinaedu'){
        this.$router.push({
          path: "/Mobile/Tracking/TrackingInfo",
          query: {
            id: this.$route.query.id,
            name: "addMychinaeduTracking"
          }
        });
      }
      if(this.queryName=='myXuecoo'){
        this.$router.push({
          path: "/Mobile/Tracking/TrackingInfo",
          query: {
            id: this.$route.query.id,
            name: "addMyXuecooTracking"
          }
        });
      }
      if(this.queryName=='myschool'){
        this.$router.push({
          path: "/Mobile/Tracking/TrackingInfo",
          query: {
            id: this.$route.query.id,
            name: "addMySchoolTracking"
          }
        });
      }
    },
    // 判断是哪个页面过来的
    getPageParams() {
      if (this.queryName == "myschool") {
        this.myschool = true;
      }
      if (this.queryName == "mychinaedu"||this.queryName == "myXuecoo") {
        this.mychinaedu = true;
      }
    },
    getChinaeduData() {
      this.$api.agent
        .investmentQueryAgentIfo({
          customerId: this.$route.query.id
        })
        .then(res => {
          
          this.investmentDataFromType=localStorage.getItem('investmentSource')
          JSON.parse(this.investmentDataFromType).forEach(item=>{
            if(item.key==res.investmentInfo.customerSource){
              res.investmentInfo.customerSource=item.value
            }
          })
          this.investmentType=localStorage.getItem('investmentType')
          JSON.parse(this.investmentType).forEach(item=>{
            if(item.key==res.investmentInfo.customerType){
              res.investmentInfo.customerType=item.value
            }
          })
          this.investmentProgress=localStorage.getItem('investmentProgress')
          JSON.parse(this.investmentProgress).forEach(item=>{
            if(item.key==res.investmentInfo.customerProgress){
              res.investmentInfo.customerProgress=item.value
            }
          })
          this.dataList = res.investmentInfo;
          
          console.log(this.dataList );
        });
      // 签约信息
      this.$api.agent
        .investmentQuerySignInfo({
          customerId: this.$route.query.id
        })
        .then(res => {
          this.investmentSignInfo = res.investmentSignInfo;
        });
      // 跟进
      this.$api.agent
        .investmentTrackingInfoChinaedu(
          {
            customerId: this.$route.query.id
          },
          this.page
        )
        .then(res => {
          this.cardTrackingData = res.investmentTrackingVos;
          this.cardTrackingData.forEach(item => {
            item.isTrackingInfoData = "isTrackingInfoData";
          });
          if (this.cardTrackingData == "") {
            this.iscardTrackingDataBlank == true;
          } else {
            this.iscardTrackingDataBlank == true;
          }
        });
    },
    getSchoolData() {
      // 查询详情
      this.$api.school
        .schoolQueryInfo({ id: this.$route.query.id })
        .then(res => {
          this.schoolInfo = res.schoolInfo;
        });
      // 查询报备
      this.$api.school
        .detailRecordInfo(
          {
            id: this.$route.query.id
          },
          this.page
        )
        .then(res => {
          this.recordInfoData = res.trackLists;
          this.recordInfoData.forEach(item => {
            item.isRecordInfoData = "isRecordInfoData";
          });
          console.log(res);
        });
    },
    upCallback(params) {
      console.log(params);
    }
  },
  mounted() {
    this.getPageParams();
    if (this.$route.query.name == "mychinaedu"||this.$route.query.name == "myXuecoo") {
      this.getChinaeduData();
    }
    if (this.$route.query.name == "myschool") {
      this.getSchoolData();
    }
  }
};
</script>

<style scoped lang="scss">
.infos {
  .trackingBox {
    .trackingBoxTitle {
      text-align: left;
      color: #333;
      font-weight: bold;
      font-size: 0.56rem;
      margin: 0.4rem 0;
    }
  }
}
.toSeeTrackingInfo{
  width: 8.1rem;
  height: 1.2rem;
  line-height: 1.2rem;
  background:linear-gradient(90deg,rgba(255,147,0,1) 0%,rgba(255,78,0,1) 100%);
  border-radius: 0.58rem;
  margin: 0 auto;
  color: #fff;
  text-align: center;
  font-size: 0.48rem;
  margin-top: 0.69rem;
}
</style>
